#include <pthread.h>
// gcc -w terminate.c -pthread
// without error checking @ pthread_create

void* thread_fn1(void* arg) {
	printf("thread 1 exit in 3sec\n");
	sleep(3);
	pthread_exit((void*)2);
}

void* thread_fn2(void* arg) {
	printf("thread 2 return in 5sec\n");
	sleep(5);
	return ((void*)2);
}

void main(void) {
	pthread_t tid1, tid2;
	pthread_create(&tid1, NULL, thread_fn1, NULL);
	pthread_create(&tid2, NULL, thread_fn2, NULL);

	void* tret;
	pthread_join(tid1, &tret);
	printf("after join tid1,exit code %d\n", (int)tret);

	pthread_join(tid2, &tret);
	printf("after join tid2,exit code %d\n", (int)tret);
}


